# -*- codeing = utf-8 -*-
# @Time : 2021/2/23 15:24
# @Atuthor: 朱朱
# @File: 074自定义可变参数.py
# @Software: PyCharm
""
"""
# *args 表示可变位置参数
# **kwargs 表示可变的关键字参数
"""
# def add(a,b):
#     return a+b
#
# def add_many(mmp):
#     x = 0
#     for n in mmp:
#         x = x+n
#     return x
#
# nums = [1, 2, 3, 4, 5, 9, 10, 12]
# print(add_many(nums))
# print(add_many((5,8,9,8,7)))
# print(add_many(range(2,19)))
#
# # 一次input只能接收一次用户的输入
# x = input('请输入多个数据,数据中间用,分割:')
# nums_input = x.split(',')
# print(nums_input)
#
# nums_input2 = []
# while True:
#     num = input('请输入数字,输入exit退出输入')
#     if num == 'exit':
#         break
#     nums_input2.append(int(num))
#     print(nums_input2)
#
# print(nums_input2)
#-------------------------------------------------
def add (a,b,*args,mul=1,**kwargs):
    # print(f'a={a},b={b}')
    print(f'args={args}') # 多出来的可变参数,会以元组的形式保存到args中
    print(f'kwargs={kwargs}')
    c = a+b
    for arg in args:
        c+=arg
    return c*mul




add(1,3,5,7,mul=2,x=0,y=4) # 多出来的关键字参数,会以字典的形式保存到kwargs中
rs = add(1,3,5,7,mul=2,x=0,y=4) # 多出来的关键字参数,会以字典的形式保存到kwargs中
print(rs)
add(9, 5, 4, 2, 0, p=9, q=10)
add(8, 9, 7, 5, 7, 9, 8, 7, 5, 3, t=0, m=5)

